package de.slothsoft.commons.swing.util;

import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import de.slothsoft.commons.debug.Console;

final class KeyMessages {

	private static String BUNDLE_NAME = "de.slothsoft.commons.swing.util.keys"; //$NON-NLS-1$
	private static ResourceBundle bundle;

	static {
		try {
			bundle = ResourceBundle.getBundle(BUNDLE_NAME);
		} catch (MissingResourceException e) {
			// the resource bundle cannot be found
			Console.error(e.getMessage());
		}
	}

	public static String getString(String key, Object... arguments) {
		return MessageFormat.format(getString(key), arguments);
	}

	public static String getString(String key) {
		try {
			return bundle.getString(key);
		} catch (MissingResourceException e) {
			return key;
		}
	}

	private KeyMessages() {
		// hide message class
	}

}
